#!/usr/bin/bash

# 磁盘到达70%警告

# sudo apt install mailutils
# 打开邮件
# mail
# 删除第一封邮件
# d 1

disk_use=$(df -Th | grep "/$" | awk '{print $(NF-1)}' | awk -F"%" '{print $1}')
mail_user="alice"

# useradd alice

if [ "$disk_use" -ge 9 ];then 
    echo "$(date +%F-%H) disk:${disk_use}%" | mail -s "disk warning..." "$mail_user"
fi